package com.work.shart.gender;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;

import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.work.shart.common.mybatis.controller.BaseController;
import com.work.shart.common.mybatis.entity.BaseEntity;
import com.work.shart.common.mybatis.service.IBaseMapper;
import com.work.shart.common.mybatis.service.IBaseService;
import com.work.shart.common.mybatis.service.impl.BaseServiceImpl;

public class Gender {

    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://121.199.164.8:3306/retailers_test", "root", "Liucong@123")
                .globalConfig(builder -> {
                    builder.author("cong") // 设置作者
                            .commentDate("yyyy-MM-dd")
                            .outputDir("D://retailers-test"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.work.shart.user") // 设置父包名
                            .moduleName("") ;// 设置父包模块名
//                            .pathInfo(Collections.singletonMap(OutputFile.mapper, "D://")); // 设置mapperXml生成路径
                })
                .templateConfig(builder -> {
                    builder.entity("templates/entity1.java")
                            .controller("templates/controller1.java");
                })
                .strategyConfig(builder -> {
                    builder.addInclude("sys_user");
                    builder.entityBuilder()
                            .superClass(BaseEntity.class)
                            .enableLombok()
                            .enableTableFieldAnnotation()
                            .naming(NamingStrategy.underline_to_camel)
                            .addSuperEntityColumns("id","create_date","update_date","del_flag","create_by","update_by")
                            .formatFileName("%sEntity")
                            .idType(IdType.INPUT);
                    builder.controllerBuilder()
                            .superClass(BaseController.class)
                            .enableRestStyle();
                    builder.serviceBuilder()
                            .superServiceClass(IBaseService.class)
                            .superServiceImplClass(BaseServiceImpl.class);
                    builder.mapperBuilder()
                            .superClass(IBaseMapper.class)
                            .enableMapperAnnotation()
                            .enableBaseResultMap();
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
